import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from "path"; // 尝试将相对路径转成绝对路径
// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    //别名、后缀
    alias: {
      "@": resolve(__dirname, "src"),
    },
    extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
  },
  server: {
    proxy: {
      "/api": {
        target: "http://localhost:3000",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
})
